<template>
  <d2-container>
    <template slot="header">
      <div style="display: flex;width: 90%">
        <div style="width: 80%">
          <el-descriptions title="基础信息：">
            <el-descriptions-item label="考核号">{{ revalues.appraisalNo }}</el-descriptions-item>
            <el-descriptions-item label="考核名称">{{ revalues.assessName }}</el-descriptions-item>
            <el-descriptions-item label="考核类型">{{ revalues.assessType }}</el-descriptions-item>
            <el-descriptions-item label="创建时间">{{ revalues.createTime }}</el-descriptions-item>
            <el-descriptions-item label="审核人">{{ revalues.checkInfoName }}</el-descriptions-item>
          </el-descriptions>
        </div>
        <div style="width: 20%">
          <div style="display: flex;align-items: center">状态：<h2 style="margin: 0;">{{ revalues.status }}</h2></div>
          <div style="display: flex;align-items: center">得分：<h2>{{ revalues.score }}</h2></div>
        </div>
      </div>
    </template>

    <div>
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>用户自评：</span>
          <el-link :underline="false" :href="'http://'+this.userInfo.filePath" style="float: right;  padding: 3px 0" type="primary">查看附件</el-link>
        </div>
        <div class="text item">
          {{this.userInfo.selfReview}}
        </div>
      </el-card>
    </div>

    <div style="box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)">
      <div style="padding: 1em;display: flex; width:90%">
        <div style="width: 50%">
          <el-card class="box-card" shadow="never">
            <div slot="header" class="clearfix">
              <span>评分标准：</span>
            </div>
            {{revalues.assessMethod}}
          </el-card>
        </div>

        <div style="width: 50%;display: flex; flex-direction: column">
          <div style="margin-left: 5%;width: 100%">
            <h2>请您进行评分：</h2>
            <div class="block" style="width: 100%">
              <el-slider
                v-model="score"
                :disabled="loading"
                show-input>
              </el-slider>
            </div>
          </div>
          <div style="display: flex;justify-content: center;margin-top: 1em">
            <el-button type="primary" size="mini" @click="exitScort" :loading="loading">取消评分</el-button>
            <el-button type="primary" size="mini" @click="handleRemove" :loading="loading">重置分数</el-button>
            <el-button type="primary" v-loading.fullscreen.lock="fullscreenLoading" size="mini" @click="upScort" :loading="loading">确认提交</el-button>
          </div>
        </div>

      </div>
    </div>
  </d2-container>
</template>

<script>
export default {
  name: 'startScoring',
  data () {
    return {
      fileList: [],
      textarea: '',
      fullscreenLoading: false,
      loading: false
    }
  },
  methods: {
    handleRemove () {
      this.score = 0
    },
    upScort () {
      this.loading = true
      this.fullscreenLoading = true
      this.$request({ url: '/checkInfo/checkUser', method: 'post', data: { userId: this.revalues.uid, score: this.score, detailsId: this.revalues.detailsId, status: 1 } })
        .then((res) => {
          this.$emit('upScort', res)
          if (res >= 1) {
            this.loading = false
            this.fullscreenLoading = false
            this.exitScort()
          } else {
            this.$message.error('打分失败')
            this.exitScort()
          }
        })
    },
    exitScort () {
      this.$emit('exitScort', false)
      this.handleRemove()
    },
    handlePreview (file) {
      console.log(file)
    },
    handleChange (file, fileList) {
      this.fileList = fileList
    }

  },
  props: {
    revalues: {
      type: Object,
      default: null
    },
    userInfo: {
      type: Object,
      default: null
    },
    score: {
      type: Number,
      default: 0
    }
  }
}
</script>

<style scoped>
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both
}

.box-card {
  width: 100%;
  margin-top: 0;
  margin-left: 0;
}
</style>
